/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.totoBD.gui.swing.components.dialog;

import com.totoBD.gui.swing.components.button.BtnCmdApply;
import com.totoBD.gui.swing.components.button.BtnCmdCancel;
import com.totoBD.gui.swing.components.button.BtnCmdOk;
import com.totoBD.gui.swing.components.panel.PnlBtnGrpCommand;
import com.totoBD.jdbc.DbConnectionSingleton;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author rgil
 */
public abstract class DlgConAbs extends DlgAbs implements ActionListener{
    public DlgConAbs(String textDescription,
            Frame parent,
            boolean modal) throws Exception{

        super(parent, modal);
         this.lst_ = (ActionListener) this;
         this._dbConnection_ = DbConnectionSingleton.getSingletonObject();
         this.lblTextBoxdef = new JLabel(textDescription);
         this.tmkGuiShrBtnGrpCommand = new PnlBtnGrpCommand(lst_);
    }
    protected void _close_(){
        this.dispose();
    }
    protected abstract boolean _doJob() throws Exception;
    
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() instanceof BtnCmdApply){
                try {
                    _doJob();
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    DlgBoxError dlg = new DlgBoxError(ex.getMessage());
                }
            }
            else if (e.getSource() instanceof BtnCmdOk){
                try {
                    if(_doJob()) {
                        _close_();
                    }
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    DlgBoxError dlg = new DlgBoxError(ex.getMessage());
                }
            }
            else if (e.getSource() instanceof BtnCmdCancel) {
               _close_();
            }
    }

    protected JPanel tmkGuiShrBtnGrpCommand;
    protected JTextField txfDataBaseName;
    protected JLabel lblTextBoxdef;
    protected DbConnectionSingleton _dbConnection_;
    protected ActionListener lst_=null;



}
